package cn.good.yan.feign;

import cn.good.yan.feign.impl.PaymentFallbackServiceImpl;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * Feign 的配置
 * FeignClient注解，value=服务名
 * fallback  服务降级 - 处理类
 *
 * @author shengren.yan
 * @create 2023-12-27
 */
@Service
@FeignClient(contextId = "PaymentHystrixService", value = "CLOUD1-PROVIDER", fallback = PaymentFallbackServiceImpl.class)
public interface PaymentHystrixService {

    // 正常请求 - 服务端的接口
    @GetMapping("/t1/hystrix/{id}")
    String paymentInfoOk(@PathVariable("id") Integer id);

    // 超时请求 - 服务端的接口
    @GetMapping("/t1/hystrix/timeout/{id}")
    String paymentInfoTimeOut(@PathVariable("id") Integer id);

    // 服务熔断 请求 - 服务端的接口
    @GetMapping("/t1/hystrix/circuit/{id}")
    String circuit(@PathVariable("id") Integer id);

}
